<?php
/*
+-----------------------------------------------------------------------------+
| $Id: *.php 2009-08-18 08:41:22Z Bleakwind $
| Copyright (c) 2003-2010 Bleakwind (www.weaverdream.com)
| http://www.weaverdream.com/
+-----------------------------------------------------------------------------+
*/

if (!defined( 'ENTRY_INDEX')){
    echo "<h1>Forbidden</h1><p>You don't have permission to access on this server.</p>";
    exit;
}

if( !preg_match("/^[1-9][0-9]*$/",$sys->get['friendlink_id'])  ){
    $sys->prompt("failed",$LANGUAGE['s']['friendlink']['friendlink_id_error']."<!-- friendlink_id_error -->");
}else{
    
    $friendlink_info = $sys->return_friendlink_info($sys->get['friendlink_id']);

    if ( ($friendlink_info['if_enable'] == "2") ||
         ($friendlink_info['if_enable'] == "3" && ($friendlink_info['if_enable_begin'] > $sys->nowtime || $friendlink_info['if_enable_end'] < $sys->nowtime))
       ) {
        $sys->prompt("failed",$LANGUAGE['s']['friendlink']['friendlink_if_enable_no']."<!-- friendlink_if_enable_no -->");
    }

    $friendlink_info['detail_list']    = explode("[PAGESPLIT]", $friendlink_info['detail']);
    $friendlink_info['detail_num']     = count($friendlink_info['detail_list']);
    $total_record                   = $friendlink_info['detail_num'];
    $bwpage->set_record_listnum(1);
    $bwpage->set_record($total_record);
    $bwpage->page($CONFIGURE['common']['control_index']."?act=friendlink&friendlink_id=".$sys->get['friendlink_id']."&pag=%s");
    $friendlink_info['detail_current'] = $friendlink_info['detail_list'][$bwpage->record_listfirst];

    $friendlink_info['attach']     = func::db_select(DB_TABLE_FRIENDLINK_ATTACH, "*", "friendlink_id=".$friendlink_info['id'], "", "id");

    $sql_data = array(
        "click" => "click+1",
    );
    $result = func::db_update(DB_TABLE_FRIENDLINK, $sql_data, "id=".$friendlink_info['id']);

    if ($friendlink_info['if_turn'] == "1") {
        $sys->prompt("jump",$friendlink_info['if_turn_url']);
    }
    $t->assign(array(
        "friendlink_info"      => $friendlink_info,
        "pagination"        => $bwpage->pagination,
    ));
}
$public_var['page_place'][] = $LANGUAGE['s']['friendlink']['page_place'];
$public_var['page_place'][] = $friendlink_info['subject'];
?>
